package cn.hs.service.impl;

import cn.hs.entity.Mynotice;
import cn.hs.mapper.MynoticeMapper;
import cn.hs.service.MynoticeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName MynoticeServiceImpl
 * @Description TODO
 * @Author CnYuu
 * @Date 2024年10月23日 19:05
 * @Version 1.0
 */
@Service
public class MynoticeServiceImpl implements MynoticeService {
    @Autowired
    private MynoticeMapper mynoticeMapper;
    @Override
    public PageInfo findAll(Integer pageNum, Integer pageSize, Mynotice mynotice) {
        PageHelper.startPage(pageNum, pageSize);
        List<Mynotice> mynotices = mynoticeMapper.selectAll(mynotice);
        PageInfo<Mynotice> pageInfo = new PageInfo<>(mynotices);
        return pageInfo;
    }

    @Override
    public int insert(Mynotice mynotice) {
        return mynoticeMapper.insertAll(mynotice);
    }

    @Override
    public int update(Mynotice mynotice) {
        return mynoticeMapper.updateSelective(mynotice);
    }

    @Override
    public int delete(int id) {
        return mynoticeMapper.deleteById(id);
    }

    @Override
    public List<Mynotice> selectByUserId(Integer userId) {
        return mynoticeMapper.selectByUserId(userId);
    }
}
